import React from "react";
import {NavigationContainer, DefaultTheme} from "@react-navigation/native";
import {useTheme} from "@rn-vui/themed";
import DrawerNavigator from "./DrawerNavigator.tsx";
import Login from "../pages/auth/Login.tsx";
import {RootSiblingParent} from "react-native-root-siblings";
import {useIsAuthenticated} from "../pages/hooks/hooks.tsx";

const AppContainer = () => {
    const {theme} = useTheme();
    const isAuthenticated = useIsAuthenticated();

    if (isAuthenticated) {
        return (
            <NavigationContainer
                theme={{
                    ...DefaultTheme,
                    colors: {
                        primary: theme?.colors?.primary,
                        background: theme?.colors?.black,
                        card: theme?.colors?.white,
                        text: theme?.colors?.black,
                        border: theme?.colors?.grey3,
                        notification: theme?.colors?.red,
                    },
                    dark: false,
                }}
            >
                <RootSiblingParent>
                    <DrawerNavigator/>
                </RootSiblingParent>
            </NavigationContainer>
        );
    } else {
        return <Login/>;
    }
};

export default AppContainer;
